package UIPackage;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

import org.dyno.visual.swing.layouts.Constraints;
import org.dyno.visual.swing.layouts.GroupLayout;
import org.dyno.visual.swing.layouts.Leading;

import Sistem.Register;

//VS4E -- DO NOT REMOVE THIS LINE!
public class AnasayfaYoneticiGUI extends JFrame {

	private static final long serialVersionUID = 1L;
	private JButton jButton0;
	private JTextField jTextField0;
	private JTextField jTextField1;
	private JButton jButton1;
	private JButton jButton2;
	private JButton jButton3;
	private JButton jButton4;
	private JButton jButton5;
	private Register r;
	private JButton jButton6;
	private static final String PREFERRED_LOOK_AND_FEEL = "javax.swing.plaf.metal.MetalLookAndFeel";
	public AnasayfaYoneticiGUI() {
		initComponents();
	}
	public AnasayfaYoneticiGUI(Register r){
		this.r=r;
		initComponents();
	}
	
	private void initComponents() {
		setLayout(new GroupLayout());
		add(getJTextField0(), new Constraints(new Leading(46, 133, 10, 10), new Leading(27, 25, 12, 12)));
		add(getJTextField1(), new Constraints(new Leading(46, 132, 12, 12), new Leading(64, 25, 12, 12)));
		add(getJButton1(), new Constraints(new Leading(203, 226, 12, 12), new Leading(66, 12, 12)));
		add(getJButton2(), new Constraints(new Leading(203, 226, 12, 12), new Leading(107, 12, 12)));
		add(getJButton4(), new Constraints(new Leading(203, 226, 12, 12), new Leading(147, 10, 10)));
		add(getJButton3(), new Constraints(new Leading(203, 226, 12, 12), new Leading(186, 10, 10)));
		add(getJButton5(), new Constraints(new Leading(203, 226, 12, 12), new Leading(223, 12, 12)));
		add(getJButton0(), new Constraints(new Leading(203, 226, 12, 12), new Leading(27, 12, 12)));
		add(getJButton6(), new Constraints(new Leading(203, 226, 12, 12), new Leading(263, 10, 10)));
		setSize(492, 343);
	}
	private JButton getJButton6() {
		if (jButton6 == null) {
			jButton6 = new JButton();
			jButton6.setText("Uçuş Listeleme");
			jButton6.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton6MouseMouseClicked(event);
				}
			});
		}
		return jButton6;
	}
	private JButton getJButton5() {
		if (jButton5 == null) {
			jButton5 = new JButton();
			jButton5.setText("Uçuş Oluşturma");
			jButton5.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton5MouseMouseClicked(event);
				}
			});
		}
		return jButton5;
	}
	private JButton getJButton4() {
		if (jButton4 == null) {
			jButton4 = new JButton();
			jButton4.setText("Havalimanı Ekleme");
			jButton4.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton4MouseMouseClicked(event);
				}
			});
		}
		return jButton4;
	}
	private JButton getJButton3() {
		if (jButton3 == null) {
			jButton3 = new JButton();
			jButton3.setText("Sefer Ekleme");
			jButton3.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton3MouseMouseClicked(event);
				}
			});
		}
		return jButton3;
	}
	private JButton getJButton2() {
		if (jButton2 == null) {
			jButton2 = new JButton();
			jButton2.setText("Uçak Ekleme");
			jButton2.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton2MouseMouseClicked(event);
				}
			});
		}
		return jButton2;
	}
	private JButton getJButton1() {
		if (jButton1 == null) {
			jButton1 = new JButton();
			jButton1.setText("Pilot Ekleme");
			jButton1.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton1MouseMouseClicked(event);
				}
			});
		}
		return jButton1;
	}
	private JTextField getJTextField1() {
		if (jTextField1 == null) {
			jTextField1 = new JTextField();
		}
		return jTextField1;
	}
	private JTextField getJTextField0() {
		if (jTextField0 == null) {
			jTextField0 = new JTextField();
		}
		return jTextField0;
	}
	private JButton getJButton0() {
		if (jButton0 == null) {
			jButton0 = new JButton();
			jButton0.setText("Satış Elemanı Ekleme");
			jButton0.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton0MouseMouseClicked(event);
				}
			});
		}
		return jButton0;
	}
	private static void installLnF() {
		try {
			String lnfClassname = PREFERRED_LOOK_AND_FEEL;
			if (lnfClassname == null)
				lnfClassname = UIManager.getCrossPlatformLookAndFeelClassName();
			UIManager.setLookAndFeel(lnfClassname);
		} catch (Exception e) {
			System.err.println("Cannot install " + PREFERRED_LOOK_AND_FEEL
					+ " on this platform:" + e.getMessage());
		}
	}

	/**
	 * Main entry of the class.
	 * Note: This class is only created so that you can easily preview the result at runtime.
	 * It is not expected to be managed by the designer.
	 * You can modify it as you like.
	 */
	public static void main(String[] args) {
		installLnF();
		SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				AnasayfaYoneticiGUI frame = new AnasayfaYoneticiGUI();
				frame.setDefaultCloseOperation(AnasayfaYoneticiGUI.EXIT_ON_CLOSE);
				frame.setTitle("AnasayfaYönetici");
				frame.getContentPane().setPreferredSize(frame.getSize());
				frame.pack();
				frame.setLocationRelativeTo(null);
				frame.setVisible(true);
			}
		});
	}


	private void jButton0MouseMouseClicked(MouseEvent event) {
		try {
			Integer.parseInt(jTextField0.getText());
			int elemanID=Integer.parseInt(getJTextField0().getText());
			r.satisElemaniEklemeIsleminiBaslat(elemanID);
			SatisElemaniEkleGUI form = new SatisElemaniEkleGUI(r);
			form.show();
		} catch (NumberFormatException e) {
		    System.out.println("Satiş Elemani id giriniz!");
		}
	}

	private void jButton1MouseMouseClicked(MouseEvent event) {
		try {
			Integer.parseInt(jTextField1.getText());	
			int pilotID=Integer.parseInt(getJTextField1().getText());
			r.pilotEklemeIsleminiBaslat(pilotID);
			PilotEkleGUI form = new PilotEkleGUI(r);
			form.show();
		}catch (NumberFormatException e) {
			System.out.println("pilot id giriniz!");
		}
	}

	private void jButton2MouseMouseClicked(MouseEvent event) {
		r.ucakEklemeIsleminiBaslat();
		UcakEkleGUI form = new UcakEkleGUI(r);
		form.show();
	}

	private void jButton3MouseMouseClicked(MouseEvent event) {
		r.seferEklemeIsleminiBaslat();
		SeferIdGUI form = new SeferIdGUI(r);
		form.show();
	}

	private void jButton4MouseMouseClicked(MouseEvent event) {
		r.havalimaniEklemeIsleminiBaslat();
		HavalimaniIdGUI form = new HavalimaniIdGUI(r);
		form.show();
	}

	private void jButton5MouseMouseClicked(MouseEvent event) {
		UcusOlusturmaGUI form = new UcusOlusturmaGUI(r);
		form.show();
	}
	private void jButton6MouseMouseClicked(MouseEvent event) {
		ucusListelemeGUI form = new ucusListelemeGUI(r);
		form.show();
	}
	
}
